<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>车辆资产信息</title>
    <link rel="stylesheet" href="../../js/bower_components/bootstrap/dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="../../js/bower_components/bootstrap-select/dist/css/bootstrap-select.min.css">
    <link rel="stylesheet" href="../../js/bower_components/bootstrap-switch/dist/css/bootstrap3/bootstrap-switch.min.css">
    <link rel="stylesheet" href="../../js/bower_components/bootstrap-table/dist/bootstrap-table.min.css">
    <link rel="stylesheet" href="../../js/bower_components/bootstrap-treeview/dist/bootstrap-treeview.min.css">

    <script src="../../js/bower_components/jquery/dist/jquery.min.js"></script>
    <script src="../../js/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
    <script src="../../js/bower_components/bootbox.min.js"></script>
    <script src="../../js/bower_components/bootstrap-select/js/bootstrap-select.js"></script>
    <script src="../../js/bower_components/bootstrap-switch/dist/js/bootstrap-switch.min.js"></script>
    <script src="../../js/bower_components/bootstrap-table/dist/bootstrap-table.min.js"></script>
    <script src="../../js/bower_components/bootstrap-table/dist/locale/bootstrap-table-zh-CN.js"></script>
    <script src="../../js/bower_components/bootstrap-treeview/dist/bootstrap-treeview.min.js"></script>
    <script src="../../js/bower_components/jquery-form-validator/form-validator/jquery.form-validator.min.js"></script>
    <script src="../../js/bower_components/moment/min/moment-with-locales.min.js"></script>
    <script>
		$(function () {
			$("#btnAdd").click(function () {
				console.log("模态框的打开方法===1");
				$("#divForm").modal();
				console.log("模态框的打开方法===2");
            })
                $("#btnInstockShow").click(function () {
                console.log("模态框的打开方法===3");
                $("#divAssetsInstock").modal();
                console.log("模态框的打开方法===4");
            })
            $("#btnEdit").click(function () {
                console.log("模态框的打开方法===5");
                $("#divAssetsInfo").modal();
                console.log("模态框的打开方法===6");
			})
			//搜索按钮
			$("#btnSearch").click(function () {
				console.log("进入搜索按钮的方法");
				//获取界面当中的控件的值
				var form = $("#txt").val();
				console.log(form);
				var formcarbrand = $("#selcarbrand").selectpicker('val');
				console.log(formcarbrand);
				//整理查询条件
				var user = "?";
				if (form != "") {
					user += "=" + form
					if (formcarbrand != "" || formcarbrand != "全部") {
						user += "&carbrand=" + formcarbrand
					}
				}
				else if (formcarbrand != "") {
					if (formcarbrand != "全部") {
						if (user != "") {
							user += "&carbrand=" + formcarbrand
						} else {
							user += "carbrand=" + formcarbrand
						}
					}
				}

				console.log(user);

				//到后端去查询

				$.ajax({
					type: "get",
					dataType: "json",
					url: "http://121.37.241.58:8883/logic/baseInfo/category/list/2" + user,
					success: function (res) {
						inittable(res);
					}
				})
			})

			initcarbrand();
			inittable("");
			initcarbrandForm();
		});

		function initcarbrand() {
			$("#selcarbrand").empty;
			$.ajax({
				type: "get",
				url: "http://121.37.241.58:8883/logic/baseInfo/category/list/2",
				dataType: "json",
				success: function (res) {
					console.log(res);
					if (!res.flag) {
						$.each(res, function (i, n) {
							$("#selcarbrand").append("<option value=\"" + n.carbrand + "\">" + n.carbrand + "</option>")
						});
						$("#selcarbrand").append("<option value='全部'>全部</option>");
						$("#selcarbrand").selectpicker('refresh');
					}
				}
			})
		}


		function initcarbrandForm() {
			$("#selcarbrandForm").empty;
			$.ajax({
				type: "get",
				url: "",
				dataType: "json",
				success: function (res) {
					console.log(res);
					if (!res.flag) {
						$.each(res, function (i, n) {
							$("#selcarbrandForm").append("<option value=\"" + n.carbrand + "\">" + n.carbrand + "</option>")
						});
						$("#selcarbrandForm").selectpicker('refresh');
					}
				}
			})
		}


		function inittable(myData) {
			console.log(myData + ":默认值")
			$("#tblResult").bootstrapTable("destroy");
			var form = $("#txt").val();
			var formcarbrand = $("#selcarbrand").selectpicker('val');
			if (myData == "") {
				if (form == "" || formcarbrand == "") {
					console.log("进入无参的方法")
					$("#tblResult").bootstrapTable({
						loadMsg: "正在加载数据....",
						url: "",
						//data:res,
						sidePagination: 'client',
						pageSize: "6",
						Pageinatin: true,
						idField: "id",
						columns: [{
							field: "carmodel",
							title: "车辆型号",
							halign: 'center'
						}, {
							field: "namecn",
							title: "资产名称",
							halign: 'center'
						}, {
							field: "carbrand",
							title: "车辆品牌",
							halign: 'center'
						}, {
							field: "engineinfo",
							title: "发动机信息",
							halign: 'center'
						}, {
							field: "comment",
							title: "查询结果",
							halign: 'center'
						}
						]

					})
				} else {
					console.log("进入无参的方法")

					$("#tblResult").bootstrapTable({
						loadMsg: "正在加载数据....",
						//url:"http://121.37.241.8:8883/logic/baseInfo/category/list/4",
						data: myData,
						sidePagination: 'client',
						pageSize: "",
						Pageinatin: true,
						idField: "id",
						columns: [{
							field: "carmodel",
							title: "车辆型号",
							halign: 'center'
						}, {
							field: "namecn",
							title: "资产名称",
							halign: 'center'
						}, {
							field: "carbrand",
							title: "车辆品牌",
							halign: 'center'
						}, {
							field: "comment",
							title: "关联账号",
							halign: 'center'
						}, {
							field: "engineinfo",
							title: "发动机信息",
							halign: 'center'
						}, {
							field: "comment",
							title: "查询结果",
							halign: 'center'
						}]
					})
				}
			} else {
				console.log("进入条件查询");
				$("#tblResult").bootstrapTable({
					loadMsg: "正在加载数据....",
					//url:"http://121.37.241.8:8883/logic/baseInfo/category/list/{4}",
					data: myData,
					sidePagination: 'client',
					pageSize: "",
					Pageinatin: true,
					idField: "id",
					columns: [{
						field: "carmodel",
						title: "车辆型号",
						halign: 'center'
					}, {
						field: "namecn",
						title: "资产名称",
						halign: 'center'
					}, {
						field: "carbrand",
						title: "车辆品牌",
						halign: 'center'
					}, {
						field: "refbankno",
						title: "关联账号",
						halign: 'center'
					}, {
						field: "engineinfo",
						title: "发动机信息",
						halign: 'center'
					}, {
						field: "comment",
						title: "查询结果",
						halign: 'center'
					}]
				})
			}
		}
	</script>
  
</head>
<body>
    <div class="container-fluid">
		<div class="row">
			<div id="divSearchForm" class="col-md-10">
				<div>
					<label for="selPowerType">发动机类型</label>
					<select id="selPowerType">
						<option value="-1"> 全 部 </option>
					</select>
				</div>
				<div>
					<label for="tbxCarBrand ">品牌/型号</label>
					<input type="text" id="tbxCarBrand " />
				</div>
				<div>
					<label for="ckbAutotrans">自动挡</label>
					<input type="checkbox" id="ckbAutotrans" />
				</div>
                <div>
					<label for="tblAssetsResult">查询结果</label>
					<input type="text" id="tblAssetsResult" />
				</div>
				<div>
					<button type="button" id="btnSearch" class="btn-primary">
						<span class="glyphicon glyphicon-search" /> 检索  </button>
				</div>
			</div>
			<div class="row">
				<div class="col-md-10">
					<div id="toolsButtons">
						<button type="button" id="btnAdd" class="btn-success">
							<span class="glyphicon glyphicon-plus" /> 新增资产 
						</button>
						<button type="button" id="btnInstockShow" class="btn-primary">
							<span class="glyphicon glyphicon-download-alt" /> 资产入库 
						</button>
						<button type="button" id="btnEdit" class="btn-warning">
							<span class="glyphicon glyphicon-edit" /> 编辑资产 
						</button>
					</div>
				</div>
			</div>
			<div class="row">
				<div class="col-md-10">
					<div id="divResult">
						<table id="tblResult">
							<thead>
								<tr id="resultHeader">
									<th data-halign="center" data-valign="middle">
										<span class="glyphicon glyphicon-tags" /> 资产编号
									</th>
									<th data-halign="center" data-valign="middle">资产名 称</th>
									<th data-halign="center" data-valign="middle"> 品 牌 </th>
									<th data-halign="center" data-valign="middle"> 型 号 </th>
									<th data-halign="center" data-valign="middle">发动机信息 </th>
									<th data-halign="center" data-valign="middle">查询结果</th>
								</tr>
							</thead>
							<tbody id="resultBody"></tbody>
						</table>
					</div>
				</div>
			</div>
			

			<div class="modal fade" id="divForm" tabindex="-1" parentid="dialog" aria-labelledby="myModal" aria-hidden="true">
				<div class="modal-dialog">
					<div class="modal-content">
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
							<h4 class="modal-title" id="modalTitle">新增资产</h4>
						</div>
						<div class="modal-body form-inline">
							<div class="form-group">
								<label class="control-label" for="txtcarbrand">车辆品牌</label>
								<input type="text" id="txtcarbrand" style="width: 200px;" class="form-control" />
							</div>
							<div class="form-group">
								<label class="control-label" for="txtrefBankNo">关联账号</label>
								<input type="text" id="txtrefBankNo" style="width: 200px;" class="form-control" />
							</div>
							<div class="form-group">
								<label class="control-label" for="selPowerType">资产分类</label>
								<select id="selPowerType"></select>
							</div>
							
								<div class="modal-footer">
									<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
									<button type="button" class="btn btn-primary">保存</button>
								</div>
							</div>
						</div>
					</div>
				</div>
                <div class="modal fade" id="divAssetsInstock" tabindex="-1" parentid="dialog" aria-labelledby="myModal"
                aria-hidden="true">
                <div class="modal-dialog">
                    <div class="modal-content" id="content">
                        <div class="modal-header" id="assetsInstockHead">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true"> × </button>

                            <h4 class="modal-title" id="modalTitle">资产入库</h4>

                        </div>
                        <div class="modal-body">
                            <form id="formInstock">
                                <input type="hidden" id="hidAssetsIdForInstock" value="" />
                                <div id="divInstockAlert" role="alert"></div>
                                <div id="divInstockContent">
                                    <div>
                                        <label for="tbxAssetsNameShow">资产名称：</label>
                                        <div class="input-group">
                                            <input type="text" id="tbxAssetsNameForInstock" readonly="readonly" />
                                        </div>
                                    </div>
                                    <div>
                                        <label for="tbxInstockCount">入库数量：</label>
                                        <div class="input-group">
                                            <input type="number" min="0" id="tbxInstockCount" required="required" />
                                            <span class="input-group-addon">
                                                <span class="glyphicon glyphicon-asterisk"></span>
                                            </span>
                                        </div>
                                    </div>
                                    <div>
                                        <label for="tbxInstockPrice">入库单价：</label>
                                        <div class="input-group">
                                            <span class="input-group-addon">￥</span>
                                            <input type="number" min="0" id="tbxInstockPrice" required="required" />
                                            <span class="input-group-addon">
                                                <span class="glyphicon glyphicon-asterisk"></span>
                                            </span>
                                        </div>
                                    </div>
                                    <div>
                                        <label for="tbxInstockSum">金额合计：</label>
                                        <div class="input-group">
                                            <span class="input-group-addon">￥</span>
                                            <input type="text" readonly="readonly" min="0" id="tbxTotalPrice" />
                                        </div>
                                    </div>
                                    <div>
                                        <label for="tbxInstockDate">入库时间：</label>
                                        <div class="input-group">
                                            <input type="date" id="tbxInstockDate" required="required" />
                                            <span class="input-group-addon">
                                                <span class="glyphicon glyphicon-asterisk"></span>
                                            </span>
                                        </div>
                                    </div>
                                    <div>
                                        <label for="selHandlerEmp">资产购置人：</label>
                                        <div class="input-group">
                                            <select id="selHandlerEmp" required="required"> </select>
                                        </div>
                                    </div>
                                    <div>
                                        <label for="tbxInstockComment">备注说明：</label>
                                        <div class="input-group">
                                            <textarea rows="2" id="tbxInstockComment"> </textarea>
                                        </div>
                                    </div>
                                </div>
                            </form>
                        </div>
                        
                        <div class="modal-footer">
                            <button class="btn-primary" id="btnInstock">
                                <span class="glyphicon glyphicon-save"> 入库 Instock </button>
                            <button class="btn-default" data-dismiss="modal" id=" btnCancelInstock">
                                <span class="glyphicon glyphicon-remove"> 取消 Cancel
                            </button>
                        </div>
                    </div>
                </div>
            </div>
                <div class="modal fade" id="divAssetsInfo" tabindex="-1" parentid="dialog" aria-labelledby="myModal"
                aria-hidden="true">
                <div class="modal-dialog">
                    <div class="modal-content" id="assetsInfoContent">
                        <div class="modal-header" id="assetsInfoHead">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true"> × </button>
                            <h4 class="modal-title" id="modalTitle">资产信息</h4>
                        </div>
                        <div class="modal-body">
                            <form id="formAssetsInfo">
                                <input type="hidden" id="hidAssetsId" value="" />
                                <div id="divEditAlert" role="alert"></div>
                                <div id="divEditContent">
                                    <div>
                                        <label for="tbxAssetsCodeEdit">资产编号：</label>
                                        <div class="input-group">
                                            <input type="text" id="tbxAssetsCodeEdit" readonly="readonly" />
                                        </div>
                                    </div>
                                    <div>
                                        <label for="tbxAssetsNameEdit">资产名称：</label>
                                        <div class="input-group">
                                            <input type="text" id="tbxAssetsNameEdit" required="required" />
                                            <span class="input-group-addon">
                                                <span class="glyphicon glyphicon-asterisk"></span>
                                            </span>
                                        </div>
                                    </div>
                                    <div>
                                        <label for="spanCategoryGroupEdit"> 资产分 类 : </label>
                                        <div class="input-group">
                                            <div>
                                                <select id="selCategoryEdit1" required="required"></select>
                                                <select id="selCategoryEdit2" required="required"></select>
                                            </div>
                                        </div>
                                    </div>
                                    <div>
                                        <label for="selPackageTypeEdit">包装类型：</label>
                                        <div class="input-group">
                                            <select id="selPackageTypeEdit"></select>
                                        </div>
                                    </div>
                                    <div>
                                        <label for="tbxNormalBrandEdit">品牌：</label>
                                        <div class="input-group">
                                            <input type="text" id="tbxNormalBrandEdit" required="required" />
                                            <span class="input-group-addon">
                                                <span class="glyphicon glyphicon-asterisk"></span>
                                            </span>
                                        </div>
                                    </div>
                                    <div>
                                        <label for="tbxNormalModelEdit">型号：</label>
                                        <div class="input-group">
                                            <input type="text" id="tbxNormalModelEdit" required="required" />
                                            <span class="input-group-addon">
                                                <span class="glyphicon glyphicon-asterisk"></span>
                                            </span>
                                        </div>
                                    </div>
                                    <div>
                                        <label for="tbxSupplierEdit">供货商名称：</label>
                                        <div class="input-group">
                                            <input type="text" id="tbxSupplierEdit" required="required" />
                                            <span class="input-group-addon">
                                                <span class="glyphicon glyphicon-asterisk"></span>
                                            </span>
                                        </div>
                                    </div>
                                    <div>
                                        <label for="tbxSupplierTelEdit">供货商电话：</label>
                                        <div class="input-group">
                                            <input type="tel" id="tbxSupplierTelEdit" required="required" />
                                            <span class="input-group-addon">
                                                <span class="glyphicon glyphicon-asterisk"></span>
                                            </span>
                                        </div>
                                    </div>
                                    <div>
                                        <label for="cbkConsumptiveEdit">耗材：</label>
                                        <div class="input-group">
                                            <input type="checkbox" id="cbkConsumptiveEdit" required="required" />
                                        </div>
                                    </div>
                                    <div>
                                        <label for="tbxCommentEdit">其他说明：</label>
                                        <div class="input-group">
                                            <textarea rows="2" id="tbxCommentEdit"> </textarea>
                                        </div>
                                    </div>
                                </div>
                            </form>
                        </div>
                        <div class="modal-footer">
                            <button class="btn-primary" id="btnSaveAssets">
                                <span class="glyphicon glyphicon-floppy-saved" /> 保 存 Save</button>
                            <button class="btn-default" data-dismiss="modal" id="btnCancel"> 90
                                <span class="glyphicon glyphicon-remove" /> 取 消 Cancel</button>
                        </div>
                    </div>
                </div>
            </div>
</body>
</html>